package example.guice.web.provider
import com.fasterxml.jackson.datatype.joda.JodaModule
import com.fasterxml.jackson.jaxrs.xml.JacksonJaxbXMLProvider
import grizzled.slf4j.Logging
import javax.ws.rs.Consumes
import javax.ws.rs.Produces
import javax.ws.rs.ext.Provider
import com.fasterxml.jackson.dataformat.xml.XmlMapper
import javax.ws.rs.core.MediaType._

object ExampleJacksonJaxbXMLProvider {

  def getXmlMapper() = {
    val xmlMapper = new XmlMapper()
    xmlMapper.registerModule(new JodaModule());
    xmlMapper
  }

}

@Provider
@Consumes(Array(TEXT_XML, APPLICATION_XML))
@Produces(Array(TEXT_XML, APPLICATION_XML))
class ExampleJacksonJaxbXMLProvider extends JacksonJaxbXMLProvider with Logging {

  setMapper(ExampleJacksonJaxbXMLProvider.getXmlMapper);

  configure(com.fasterxml.jackson.databind.SerializationFeature.
        WRITE_DATES_AS_TIMESTAMPS , false);

}



